class RecordSweeper < ActionController::Caching::Sweeper
  PATH = {:controller => 'site', :action => 'index'}
  # If our sweeper detects that a Post was created call this
  def after_create(record)
    expire_cache_for(record)
    #    expire_fragment(:key => "widget_archives") if record.is_a?(Post) # => 当日志创建后，更新日志归档的缓存
  end

  # If our sweeper detects that a Post was updated call this
  def after_update(record)
    expire_cache_for(record)
  end

  # If our sweeper detects that a Post was deleted call this
  def after_destroy(record)
    expire_cache_for(record)
    #    expire_fragment(:key => "widget_archives") if record.is_a?(Post)# => 当日志删除后，更新日志归档的缓存
  end

  private
  def expire_cache_for(record)
    #    expire_page(:controller => 'posts', :action => 'show')
    expire_page(record)
  end
end
